package com.talent.service.impl;

import com.talent.common.PageConstants;
import com.talent.dao.DepartMapper;
import com.talent.page.Page;
import com.talent.pojo.Depart;
import com.talent.service.DepartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartServiceImpl implements DepartService{

    @Autowired
    DepartMapper departMapper;

    @Override
    public Page<Depart> selectDepartPage(Depart depart, int currentPage) {
        Page<Depart> page = new Page<>(currentPage, PageConstants.PAGESIZE);
        List<Depart> departList = departMapper.selectDepartPage(depart, page);
        page.setResultList(departList);
        return page;
    }

    @Override
    public Depart selectById(Integer id) {
        return departMapper.selectByPrimaryKey(id);
    }

    @Override
    public int editDepart(Depart depart) {
        return departMapper.updateByPrimaryKeySelective(depart);
    }

    @Override
    public int addDepart(Depart depart) {
        return departMapper.insertSelective(depart);
    }

    @Override
    public int deleteById(Integer id) {
        return departMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int validate(String name, String code, String abbr) {
        return departMapper.validate(name, code, abbr);
    }

    @Override
    public List<Depart> selectAllDepart() {
        return departMapper.selectAllDepart();
    }

    @Override
    public Object deleteAll(String[] ids) {
        return departMapper.deleteAll(ids);
    }
}
